﻿<?php
require_once 'library/config.php';
require_once 'library/category-functions.php';
require_once 'library/product-functions.php';
require_once 'library/cart-functions.php';

$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];

$catId  = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
$pdId   = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;
date_default_timezone_set('Asia/Bangkok');
$date = date("d/m/Y");
$now = date("g:i  A");
require_once 'include/header.php';
?>
<body>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
 <tr> 
  <td colspan="3">
  <?php require_once 'include/top.php'; ?>
  </td>
 </tr>
 <tr valign="top"> 
  <td width="150" height="500" id="leftnav" border="1"> 
<?php
require_once 'include/leftNav.php';
?>
  </td>
  <td id="centerNav">
<?php
	if(isset($_GET['pa'])){
	$a=$_GET['pa'];
	if($a=="trangchu") require_once('index.php');
	if($a=="gioithieu") require_once('include/gioithieu.php');
	if($a=="lienhe") require_once('include/lienhe.php');
	if($a=="tintuc") require_once('include/tintuc.php');
	if($a=="diendan") require_once('include/diendan.php');
	if($a=="dangky") require_once('include/dangky.php');
	if($a=="dangnhap") require_once('include/dangnhap.php');
	if($a=="timkiem") require_once('include/timkiem.php');
	
} else if (isset($_GET['action'])){
	$ac=$_GET['action'];
	if($ac=="listsearch")
	{
		if(isset($_SESSION['user_name']))
			require_once 'include/search.php';
		else
			echo "<script language'javascrip'>alert('Đăng nhập trước khi search!');</script>";
	}
	else if($ac=="lienhe")
		require_once 'include/lienhe.php';
	else if($ac=="tintuc")
		require_once 'include/tintuc.php';
	else if($ac=="dangnhap")
		require_once 'include/dangnhap.php';
	else if($ac=="dangky")
		require_once 'include/dangky.php';
	else if($ac=="dangxuat")
		require_once 'include/dangxuat.php';
}
else if ($pdId) {
	require_once 'include/productDetail.php';
} else if ($catId) {
	require_once 'include/productList.php';
} else {
	require_once 'include/categoryList.php';
}
?>  
  </td>
  <td width="225" align="center" id="rightNav">
  	<table>
    	<tr>
        	<td align="left"> Bây giờ là <font color="#FF0000"><?php echo $now; ?> </font></td>
        </tr>
        <?php	if(isset($_SESSION['user_id'])){
			$name=$_SESSION['user_name']; 
			$sql = "SELECT user_last_login FROM tbl_user where user_name='$name'";
			$result = dbQuery($sql);
			$row = mysql_fetch_assoc($result);
			$user_last_login=$row['user_last_login'];
		?>
			<tr>
				<td align="left">Lần cuối <?php echo $_SESSION['user_name'];?> đăng nhập là: <br> <font color="#FF0000"><center> <?php echo $user_last_login; ?></center></font></td>
			</tr>
		<?php }
		?>
    	<tr> 
        	<td width="190" align="center"><?php require_once 'include/miniCart.php'; ?></td> 
        </tr> 
  	</table></td>
 </tr>
</table>
<?php
require_once 'include/footer.php';
?>
</body>
